import { EffectCallback, DependencyList, useState, useEffect } from 'react';
import { DebounceOptions } from '../use-debounce/debounceOptions';
import useDebounceFn from '../use-debounce-fn';
import useUpdateEffect from '../use-update-effect';
export default (
    effect: EffectCallback,
    deps?: DependencyList,
    options?: DebounceOptions
) => {
    const [flag, setFlag] = useState({})

    const { run } = useDebounceFn(() => {
        setFlag({})
    }, options)

    useEffect(() => {
        return run()
    }, deps)

    useUpdateEffect(effect, [flag])
}